package com.hmdp.controller;


import com.hmdp.dto.Result;
import com.hmdp.dto.UserDTO;
import com.hmdp.service.IFollowService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
@RestController
@RequestMapping("/follow")
public class FollowController {

    @Resource
    private IFollowService followService;

    @PutMapping("/{followUserId}/{isFollow}")
    public Result try2Follow(@PathVariable("followUserId") Long followUserId, @PathVariable("isFollow") Boolean isFollow) {
        followService.try2Follow(followUserId, isFollow);
        return Result.ok();
    }

    @GetMapping("/or/not/{followUserId}")
    public Result queryIsFollow(@PathVariable("followUserId") Long followUserId) {
        boolean isFollow = followService.queryIsFollow(followUserId);
        return Result.ok(isFollow);
    }

    @GetMapping("/common/{followUserId}")
    public Result queryCommonFollows(@PathVariable("followUserId") Long followUserId) {
        List<UserDTO> userDTOList = followService.queryCommonFollows(followUserId);
        return Result.ok(userDTOList);
    }
}
